package com.qezhhnjy.flink.source;

import cn.hutool.core.lang.UUID;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

/**
 * @author zhaoyangfu
 * @date 2021/8/27-13:19
 */
public class MySource implements SourceFunction<String> {

    private boolean running = true;

    @Override
    public void run(SourceContext<String> ctx) throws Exception {
        while (running) {
            ctx.collect(UUID.fastUUID().toString());
        }
    }

    @Override
    public void cancel() {
        running = false;
    }
}
